<?php

namespace app\admin\model\validate;

use think\Validate;

class BasicConfig extends Validate {
    protected $rule =   [
        'name' => 'require|max:20|unique:basic_config',
        'desc' => 'max:64',
        'album_skin_title' => 'require',
        'album_skin_name' => 'require|max:50',
        'skin_base_url' => 'max:225',
        'album_music' => 'require|max:225',
        'album_music_name' => 'require|max:40',
        'default_share_title' => 'max:64',
        'default_share_img' => 'max:225',
        'reward_tip' => 'require|max:64',
        'applet_app_id' => 'require',
        'applet_name' => 'require|max:24',
        'ad1' => 'max:64',
        'ad2' => 'max:64',
        'ad3' => 'max:64',
        'ad4' => 'max:64',

        /*'article_button_name' => 'require|max:24',
        'article_button_key' => 'require|max:20',
        'album_button_name' => 'require|max:24',
        'album_button_key' => 'require|max:24',
        'top_button_key' => 'require|checkTopButton',*/
        //'status' => 'number',
        //'type' => 'number',
    ];

    protected $message  =   [
        'name.require'     => '配置名称不能为空',
        'applet_app_id.require'     => '小程序名不能为空',
        'applet_name.require'     => '小程序名不能为空',
        'applet_name.max'     => '小程序名不能超过24个字符',
        'name.max'     => '配置名称最多不能超过20个字符',
        'name.unique'     => '该配置名称已经存在',
        'album_skin_title.require'     => '相册模板标题不能为空',
        'album_skin_title.max'     => '相册模板标题不能超过128个字符',
        'album_skin_name.max'     => '相册模板名称不能超过50个字符',
        'album_skin_name.require'     => '相册模板名称不能为空',
        'skin_base_url.max'     => '模板基础路径不能超过225个字符',
        'album_music.max'     => '相册默认音乐不能超过255个字符',
        'album_music.require'     => '相册默认音乐不能为空',
        'album_music_name.require'     => '默认音乐名不能为空',
        'album_music_name.max'     => '默认音乐名不能超哥40个字符',
        'default_share_title.max'     => '默认分享标题不能超过64个字符',
        'default_share_img.max'     => '默认分享图片不能超哥255个字符',
        'reward_tip.max'     => '打赏说辞不能超过64个字符',
        'ad1.max'     => '广告不能超过64个字符',
        'ad2.max'     => '广告不能超过64个字符',
        'ad3.max'     => '广告不能超过64个字符',
        'ad4.max'     => '广告不能超过64个字符',



       /* 'article_button_name.require'     => '美文默认跳转按钮不能为空',
        'article_button_name.max'     => '美文默认跳转按钮不能超过24个字符',
        'article_button_key.require'     => '美文默认跳转键不能为空',
        'article_button_key.max'     => '美文默认跳转键不能超过20个字符',
        'album_button_name.require' => '相册悬浮按钮不能为空',
        'album_button_name.max' => '相册悬浮按钮不能超过24个字符',
        'album_button_key.require' => '相册悬浮按钮键不能为空',
        'album_button_key.max' => '相册悬浮按钮键不能超过24个字符',
        'top_button_key.require' => '顶部导航按钮不能为空',*/
    ];

    private function checkTopButton($value, $rule, $data) {
        if (empty($value)) {
            return '顶部导航按钮不能为空';
        }
        foreach($value as $v) {
            if (empty($v)) {
                return '顶部导航按钮不能为空';
            }
        }
        return true;
    }

    protected $scene = [
        /*'add'  =>  ['name','theme','start_time', 'end_time', 'attention_tips', 'cover_image_url', 'sort', 'participate_num'],
        'edit'  =>  ['name','theme','start_time', 'end_time', 'attention_tips', 'cover_image_url', 'sort', 'participate_num'],*/
    ];
}